package org.itboys.product.entity;

import org.itboys.commons.CommonConstants;
import org.itboys.commons.utils.random.RandomUtils;
import org.itboys.commons.utils.time.TimeUtils;
import org.itboys.mongodb.entity.BaseLongIdEntity;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Indexed;
import org.mongodb.morphia.annotations.Transient;

import java.util.Date;

/**
 * Created by huml on 2016/4/19.
 * 订单实体
 */
@Entity(value = "Order", noClassnameStored = true)
public class Order extends BaseLongIdEntity {

    private static final long serialVersionUID = 2920799549093191553L;

    private String orderNo;//订单编号
    private Long productId;//产品id
    private String productName;//产品名称
    private String productImage;//产品主图
    @Indexed
    private Long memberId;//购买人id
    private Integer status;//订单状态
    @Indexed
    private Long sellerId;//卖家id
    private Integer payMethod;//支付方式
    private Date createTime;// 订单创建时间
    private Date updateTime;// 修改时间
    private Date finishedTime;// 订单完成时间
    private Date payTime;//付款时间
    private Date cancelTime;// 取消时间
    private String cancelReason;// 取消原因
    private String mobile;// 手机号
    private String name;// 收货人姓名
    private String address;// 收货地址
    private Long totalFee;// 原始总价(改为总价加运费)  以分为单位
    private Long expressFee;// 物流费用金额  以分为单位
    private String memo; // 订单备注
    private String express;//哪个物流公司 varchar(16) 关联数据字典表
    private String expressNo;//物流单号 varchar(32) 快递单号
    private Date sendTime;//发货时间 datetime 发货时间
    private Date receiveTime;//收货时间 datetime 收货时间
    private Integer num;//购买数量
    private String postcode;//邮编

    private Integer isDeleted = 0;
    @Transient
    private String time;
    @Transient
    private String viewFee;
    @Transient
    private String memberName;

    public Order(){
        this.orderNo = System.currentTimeMillis() + RandomUtils.getIntRandom(6);
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Long getMemberId() {
        return memberId;
    }

    public void setMemberId(Long memberId) {
        this.memberId = memberId;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Long getSellerId() {
        return sellerId;
    }

    public void setSellerId(Long sellerId) {
        this.sellerId = sellerId;
    }

    public Integer getPayMethod() {
        return payMethod;
    }

    public void setPayMethod(Integer payMethod) {
        this.payMethod = payMethod;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Date getFinishedTime() {
        return finishedTime;
    }

    public void setFinishedTime(Date finishedTime) {
        this.finishedTime = finishedTime;
    }

    public Date getPayTime() {
        return payTime;
    }

    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    public Date getCancelTime() {
        return cancelTime;
    }

    public void setCancelTime(Date cancelTime) {
        this.cancelTime = cancelTime;
    }

    public String getCancelReason() {
        return cancelReason;
    }

    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Long getTotalFee() {
        return totalFee;
    }

    public void setTotalFee(Long totalFee) {
        this.totalFee = totalFee;
    }

    public Long getExpressFee() {
        return expressFee;
    }

    public void setExpressFee(Long expressFee) {
        this.expressFee = expressFee;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public String getExpress() {
        return express;
    }

    public void setExpress(String express) {
        this.express = express;
    }

    public String getExpressNo() {
        return expressNo;
    }

    public void setExpressNo(String expressNo) {
        this.expressNo = expressNo;
    }

    public Date getSendTime() {
        return sendTime;
    }

    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }

    public Date getReceiveTime() {
        return receiveTime;
    }

    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public Integer getIsDeleted() {
        return isDeleted;
    }

    public void setIsDeleted(Integer isDeleted) {
        this.isDeleted = isDeleted;
    }

    public String getPostcode() {
        return postcode;
    }

    public void setPostcode(String postcode) {
        this.postcode = postcode;
    }

    public String getProductImage() {
        return productImage;
    }

    public void setProductImage(String productImage) {
        this.productImage = productImage;
    }

    public String getTime() {
        return TimeUtils.format(this.createTime, CommonConstants.DATE.FORMAT_DEFAULT);
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getViewFee() {
        return viewFee;
    }

    public void setViewFee(String viewFee) {
        this.viewFee = viewFee;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName;
    }

    @Override
    public String toString() {
        return "Order{" +
                "orderNo='" + orderNo + '\'' +
                ", productId=" + productId +
                ", productName='" + productName + '\'' +
                ", productImage='" + productImage + '\'' +
                ", memberId=" + memberId +
                ", status=" + status +
                ", sellerId=" + sellerId +
                ", payMethod=" + payMethod +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", finishedTime=" + finishedTime +
                ", payTime=" + payTime +
                ", cancelTime=" + cancelTime +
                ", cancelReason='" + cancelReason + '\'' +
                ", mobile='" + mobile + '\'' +
                ", name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", totalFee=" + totalFee +
                ", expressFee=" + expressFee +
                ", memo='" + memo + '\'' +
                ", express='" + express + '\'' +
                ", expressNo='" + expressNo + '\'' +
                ", sendTime=" + sendTime +
                ", receiveTime=" + receiveTime +
                ", num=" + num +
                ", postcode='" + postcode + '\'' +
                ", isDeleted=" + isDeleted +
                ", time='" + time + '\'' +
                ", viewFee='" + viewFee + '\'' +
                ", memberName='" + memberName + '\'' +
                '}';
    }
}
